winsafe\dshow\com_interfaces/
imediaseeking.rs1#![allow(non_camel_case_types, non_snake_case)]
2
3use crate::co;
4use crate::decl::*;
5use crate::dshow::vts::*;
6use crate::kernel::privs::*;
7use crate::ole::privs::*;
8use crate::prelude::*;
9
10com_interface! { IMediaSeeking: "36b73880-c2c8-11cf-8b46-00805f6cef60";
11 }
31
32impl dshow_IMediaSeeking for IMediaSeeking {}
33
34pub trait dshow_IMediaSeeking: ole_IUnknown {
43 #[must_use]
46 fn ConvertTimeFormat(
47 &self,
48 target_format: &co::TIME_FORMAT,
49 source: i64,
50 source_format: &co::TIME_FORMAT,
51 ) -> HrResult<i64> {
52 let mut target = 0i64;
53 ok_to_hrresult(unsafe {
54 (vt::<IMediaSeekingVT>(self).ConvertTimeFormat)(
55 self.ptr(),
56 &mut target,
57 pcvoid(target_format),
58 source,
59 pcvoid(source_format),
60 )
61 })
62 .map(|_| target)
63 }
64
65 #[must_use]
70 fn GetAvailable(&self) -> HrResult<(i64, i64)> {
71 let (mut early, mut late) = (0i64, 0i64);
72 ok_to_hrresult(unsafe {
73 (vt::<IMediaSeekingVT>(self).GetPositions)(self.ptr(), &mut early, &mut late)
74 })
75 .map(|_| (early, late))
76 }
77
78 #[must_use]
81 fn GetCurrentPosition(&self) -> HrResult<i64> {
82 let mut pos = 0i64;
83 ok_to_hrresult(unsafe {
84 (vt::<IMediaSeekingVT>(self).GetCurrentPosition)(self.ptr(), &mut pos)
85 })
86 .map(|_| pos)
87 }
88
89 #[must_use]
92 fn GetDuration(&self) -> HrResult<i64> {
93 let mut duration = 0i64;
94 ok_to_hrresult(unsafe {
95 (vt::<IMediaSeekingVT>(self).GetDuration)(self.ptr(), &mut duration)
96 })
97 .map(|_| duration)
98 }
99
100 #[must_use]
105 fn GetPositions(&self) -> HrResult<(i64, i64)> {
106 let (mut current, mut stop) = (0i64, 0i64);
107 ok_to_hrresult(unsafe {
108 (vt::<IMediaSeekingVT>(self).GetPositions)(self.ptr(), &mut current, &mut stop)
109 })
110 .map(|_| (current, stop))
111 }
112
113 #[must_use]
116 fn GetPreroll(&self) -> HrResult<i64> {
117 let mut preroll = 0i64;
118 ok_to_hrresult(unsafe {
119 (vt::<IMediaSeekingVT>(self).GetPreroll)(self.ptr(), &mut preroll)
120 })
121 .map(|_| preroll)
122 }
123
124 #[must_use]
127 fn GetRate(&self) -> HrResult<f64> {
128 let mut rate = f64::default();
129 ok_to_hrresult(unsafe { (vt::<IMediaSeekingVT>(self).GetRate)(self.ptr(), &mut rate) })
130 .map(|_| rate)
131 }
132
133 #[must_use]
136 fn GetStopPosition(&self) -> HrResult<i64> {
137 let mut pos = 0i64;
138 ok_to_hrresult(unsafe {
139 (vt::<IMediaSeekingVT>(self).GetStopPosition)(self.ptr(), &mut pos)
140 })
141 .map(|_| pos)
142 }
143
144 #[must_use]
147 fn GetTimeFormat(&self) -> HrResult<co::TIME_FORMAT> {
148 let mut time_guid = co::TIME_FORMAT::NONE;
149 ok_to_hrresult(unsafe {
150 (vt::<IMediaSeekingVT>(self).GetTimeFormat)(self.ptr(), pvoid(&mut time_guid))
151 })
152 .map(|_| time_guid)
153 }
154
155 fn SetPositions(
158 &self,
159 current: i64,
160 current_flags: co::SEEKING_FLAGS,
161 stop: i64,
162 stop_flags: co::SEEKING_FLAGS,
163 ) -> HrResult<()> {
164 let (mut current, mut stop) = (current, stop);
165 match unsafe {
166 co::HRESULT::from_raw((vt::<IMediaSeekingVT>(self).SetPositions)(
167 self.ptr(),
168 &mut current,
169 current_flags.raw(),
170 &mut stop,
171 stop_flags.raw(),
172 ) as _)
173 } {
174 co::HRESULT::S_OK | co::HRESULT::S_FALSE => Ok(()),
175 hr => Err(hr),
176 }
177 }
178
179 fn SetRate(&self, rate: f64) -> HrResult<()> {
182 ok_to_hrresult(unsafe { (vt::<IMediaSeekingVT>(self).SetRate)(self.ptr(), rate) })
183 }
184
185 fn SetTimeFormat(&self, format: &co::TIME_FORMAT) -> HrResult<()> {
188 ok_to_hrresult(unsafe {
189 (vt::<IMediaSeekingVT>(self).SetTimeFormat)(self.ptr(), pcvoid(format))
190 })
191 }
192}